public class Solution {
    public int lengthOfLongestSubstring(String s) {
        if (s == null || s.equals("")) return 0;
        int maxSize = 1;
        int L = 0;
        int R = 0;
        int C = 1;
        char[] chars = s.toCharArray();
        for (int i = 1; i < chars.length; i++) {

            for (int j = L; j <= R; j++) {
                if (chars[i] == chars[j]) {
                    L = j + 1; R++; C = R - L;
                    break;
                }
            }
            C++;
            R = i;
            maxSize = C > maxSize ? C : maxSize;
        }
        return maxSize;
    }
}
